package com.punai.customer.controller;

import com.punai.common.annotation.Log;
import com.punai.common.core.controller.BaseController;
import com.punai.common.core.domain.AjaxResult;
import com.punai.common.core.page.TableDataInfo;
import com.punai.common.enums.BusinessType;
import com.punai.common.utils.StringUtils;
import com.punai.customer.domain.CusGxFeatureConsume;
import com.punai.customer.domain.CusGxFee;
import com.punai.customer.domain.contants.CusConstants;
import com.punai.customer.domain.vo.CusGxFeatureConsumeVo;
import com.punai.customer.service.ICusGxFeatureConsumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 标准费用项特征描述设置耗量Controller
 * 
 * @author zhx
 * @date 2023-05-15
 */
@RestController
@RequestMapping("/cus/cusGxFeatureConsume")
public class CusGxFeatureConsumeController extends BaseController
{
    @Autowired
    private ICusGxFeatureConsumeService cusGxFeatureConsumeService;


    @GetMapping("/getFeatureDescribe")
    public TableDataInfo getFeatureDescribe(CusGxFeatureConsume cusGxFeatureConsume)
    {
        cusGxFeatureConsume.setCompanyId(getCompanyId());
        List<CusGxFeatureConsumeVo> list = cusGxFeatureConsumeService.getFeatureDescribe(cusGxFeatureConsume);
        return getDataTable(list);
    }

    @Log(title = CusConstants.GX_NAME + "设置耗量特征描述", businessType = BusinessType.DELETE)
    @DeleteMapping("/delFeatureDescribe/{id}")
    public AjaxResult delFeatureDescribe(@PathVariable("id") String id)
    {
        return AjaxResult.success(cusGxFeatureConsumeService.delFeatureDescribe(id,getCompanyId()));
    }

    @Log(title = CusConstants.GX_NAME + "恢复耗量特征描述", businessType = BusinessType.UPDATE)
    @PutMapping("/recoverFeatureDescribe")
    public AjaxResult recoverFeatureDescribe(@RequestBody CusGxFee cusGxFee)
    {
        if(StringUtils.isEmpty(cusGxFee.getId())){
            return AjaxResult.error("id获取失败");
        }
        if(StringUtils.isEmpty(cusGxFee.getAddress())){
            return AjaxResult.error("地区获取失败");
        }
        return AjaxResult.success(cusGxFeatureConsumeService.recoverFeatureDescribe(cusGxFee.getId(),cusGxFee.getAddress(),getCompanyId()));
    }
}
